﻿@{
    ViewBag.Title = "订单详情";
    Layout = "~/Views/Shared/_MallLayout.cshtml";
    var img_url = ViewBag.img_url;
}
@model token_bazaar_order_dto
<body class="page-myShareView page-order">
    @if (Model.status == EBazaarOrderStatus.Received) {
        <div class="mod-orderView market-order">
            <div class="state">
                <p class="fn28">待发货</p>
                <p class="fn48">@Model.price.ToString("f6")<em class="fn24">红钻</em></p>
                <i class="icon-time fn-right"></i>
            </div>
            <!-- 待发货1 -->
            <div class="pro mb20" >
                <div class="itemPro border-box">
                    <div class="img">
                        <img src="@(img_url+Model.product_img)" />
                    </div>
                    <div class="text">
                        <p class="fn28 fn-bold mt30">
                            @Model.product_name
                        </p>
                    </div>
                </div>
                <div class="content fn28">
                    <p class="mb30">
                        <span class="col-gray2">卖家昵称</span>
                        <span class="fn-right">@Model.seller_merchant_name</span>
                    </p>
                    <p class="mb30">
                        <span class="col-gray2">卖家账号</span>
                        <span class="fn-right">@Model.seller_merchant_mobile</span>
                    </p>
                    <p class="mb30">
                        <span class="col-gray2">订单号</span>
                        <span class="fn-right">@Model.order_no</span>
                    </p>
                    <p>
                        <span class="col-gray2">创建时间</span>
                        <span class="fn-right">@Model.create_time</span>
                    </p>
                </div>
              
            </div>
        </div>
   
    } else if (Model.status == EBazaarOrderStatus.Delivery) {
        <div class="mod-orderView market-order">
            <div class="state">
                <p class="fn28">待收货</p>
                <p class="fn48">@Model.price.ToString("f6")<em class="fn24">红钻</em></p>
                <i class="icon-time fn-right"></i>
            </div>
            @if (Model.ship_time.HasValue&&Model.ship_time.Value.AddDays(7)> DateTime.Now) {
                var time = Model.ship_time.Value.AddDays(7) - DateTime.Now;
            <div class="pro mb20">
                <div class="content">
                    <p class="fn26 col-gray"> 
                        自动收货时间
                        <span class="fn-right">@time.Days 天 @time.Hours 小时 @time.Minutes 分钟</span> 
                    </p>
                   </div>
                </div>}
                <!-- 待收货1 -->
                <div class="logistics_wray">
                    <div class="check_logistics">
                        @if (Model.shipping_type == 0) {
                            <a class="fn30" href="/BazaarOrder/OrderLogistics?id=@Model.id">查看物流信息   <em class="icon-go"></em></a>
                        }
                    </div>
                    <div class="pro mb20">
                        <div class="itemPro border-box">
                            <div class="img">
                                <img src="@(img_url+Model.product_img)" />
                            </div>
                            <div class="text">
                                <p class="fn28 fn-bold mt30">
                                    @Model.product_name
                                </p>
                            </div>
                        </div>
                        <div class="content fn28">
                            <p class="mb30">
                                <span class="col-gray2">卖家昵称</span>
                                <span class="fn-right">@Model.seller_merchant_name</span>
                            </p>
                            <p class="mb30">
                                <span class="col-gray2">卖家账号</span>
                                <span class="fn-right">@Model.seller_merchant_mobile</span>
                            </p>
                            <p class="mb30">
                                <span class="col-gray2">订单号</span>
                                <span class="fn-right">@Model.order_no</span>
                            </p>
                            <p class="mb30">
                                <span class="col-gray2">创建时间</span>
                                <span class="fn-right">@Model.create_time</span>
                            </p>
                            <p>
                                <span class="col-gray2">发货时间</span>
                                <span class="fn-right">@Model.ship_time</span>
                            </p>
                        </div>
                        <button type="button" class="closebtn fn32 btn_receive">确认收货</button>
                    </div>
                </div>
            </div>
       

    } else if (Model.status == EBazaarOrderStatus.Cancle) {
        <div class="mod-orderView market-order">
            <!-- 交易取消1 -->
            <div class="logistics_wray" >
                <div class="state">
                    <p class="fn28">交易取消</p>
                    <p class="fn48">@Model.price.ToString("f6")<em class="fn24">红钻</em></p>
                    <i class="icon-close3 fn-right"></i>
                    <p class="fn24 retus">红钻已退回对方账户</p>
                </div>
                <div class="pro mb20">
                    <div class="itemPro border-box">
                        <div class="img">
                            <img src="@(img_url+Model.product_img)" />
                        </div>
                        <div class="text">
                            <p class="fn28 fn-bold mt30">
                               @Model.product_name
                            </p>
                        </div>
                    </div>
                    <div class="content fn28">
                        <p class="mb30">
                            <span class="col-gray2">卖家昵称</span>
                            <span class="fn-right">@Model.seller_merchant_name</span>
                        </p>
                        <p class="mb30">
                            <span class="col-gray2">卖家账号</span>
                            <span class="fn-right">@Model.seller_merchant_mobile</span>
                        </p>
                        <p class="mb30">
                            <span class="col-gray2">订单号</span>
                            <span class="fn-right">@Model.order_no</span>
                        </p>
                        <p class="mb30">
                            <span class="col-gray2">创建时间</span>
                            <span class="fn-right">@Model.create_time</span>
                        </p>
                        <p>
                            <span class="col-gray2">完成时间</span>
                            <span class="fn-right">@Model.finish_time</span>
                        </p>
                    </div>
                </div>
            </div>
        </div>

    } else if (Model.status == EBazaarOrderStatus.Finish) {
        <div class="mod-orderView market-order">
            <!-- 交易完成1 -->
            <div class="logistics_wray">


                <div class="state">
                    <p class="fn28">交易完成</p>
                    <p class="fn48">@Model.price<em class="fn24">红钻</em></p>
                    <i class="icon-successful fn-right"></i>

                </div>
                <div class="check_logistics">
                    @if (Model.shipping_type == 0) {
                        <a class="fn30" href="/BazaarOrder/OrderLogistics?id=@Model.id">查看物流信息   <em class="icon-go"></em></a>
                    }
                </div>
                <div class="pro mb20">
                    <div class="itemPro border-box">
                        <div class="img">
                            <img src="@(img_url+Model.product_img)" />
                        </div>
                        <div class="text">
                            <p class="fn28 fn-bold mt30">
                                @Model.product_name
                            </p>
                        </div>
                    </div>
                    <div class="content fn28">
                        <p class="mb30">
                            <span class="col-gray2">卖家昵称</span>
                            <span class="fn-right">@Model.seller_merchant_name</span>
                        </p>
                        <p class="mb30">
                            <span class="col-gray2">卖家账号</span>
                            <span class="fn-right">@Model.seller_merchant_mobile</span>
                        </p>
                        <p class="mb30">
                            <span class="col-gray2">订单号</span>
                            <span class="fn-right">@Model.order_no</span>
                        </p>
                        <p class="mb30">
                            <span class="col-gray2">创建时间</span>
                            <span class="fn-right">@Model.create_time</span>
                        </p>
                        <p class="mb30">
                            <span class="col-gray2">发货时间</span>
                            <span class="fn-right">@Model.ship_time</span>
                        </p>
                        <p>
                            <span class="col-gray2">完成时间</span>
                            <span class="fn-right">@Model.finish_time</span>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    }
</body>
<script type="text/javascript">
    var flag = false;
    $(".btn_receive").click(function () {
        layer.confirm('您确定要收货么？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            layer.load(1);
            var id = @Model.id;
            if (flag) return;
            flag = true;
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/BazaarOrder/Receive",//url
                data: { id: id },
                success: function (result) {
                    layer.closeAll('loading');
                    if (result.result_code == 1000) {
                        layer.msg(result.result_msg);
                        setTimeout(function () {
                            location.href = '/BazaarOrder/BuyOrder'
                        }, 1000);
                    }
                    else {
                        layer.msg(result.result_msg);
                    }
                    flag = false;
                },
                error: function () {
                    layer.msg("异常！");
                    flag = false;
                }
            });
        }, function () {

        });
    });
</script>

